package com.bds.btcdc.web.service;

import com.bds.btcdc.web.model.TPairConverter;
import org.apache.log4j.Logger;
import org.nutz.dao.Cnd;
import org.nutz.dao.impl.NutDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * Created by DongChenchen on 2018/4/24 0024
 */
@Service
public class PairConverterService {
	private Logger LOGGER = org.apache.log4j.Logger.getLogger(getClass());
	@Resource
	private NutDao dao;
	public TPairConverter getOneById(Long id) {
		return dao.fetch(TPairConverter.class, Cnd.where("id", "=", id));
	}
	public List<TPairConverter> getAllUsing() {
		return dao.query(TPairConverter.class, Cnd.where("state", "=", 1));
	}
	public TPairConverter getOneByPair(String pair_name) {
		return dao.fetch(TPairConverter.class, Cnd.where("pair_name", "=",pair_name));
	}
	public List<TPairConverter> getLawerPairs() {
		return dao.query(TPairConverter.class, Cnd.where("lawerPair", "=", 1));
	}

	public Boolean updateAll(List<TPairConverter> pairs) {
		if (dao.update(pairs) == 0) {
			return false;
		}
		return true;
	}

	public Boolean updateOne(TPairConverter pairs) {
		if (dao.update(pairs) == 0) {
			return false;
		}
		return true;
	}
}